# Maintainer: Joel Holdsworth <jholdsworth@nvidia.com>

_realname=patch-ng
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.17.4
pkgrel=2
pkgdesc="Python library to parse and apply unified diffs (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
license=('spdx:MIT')
url="https://github.com/conan-io/python-patch-ng"
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/conan-io/python-${_realname}/archive/${pkgver}.tar.gz")
sha256sums=('e332ea2c2e64e95b988c6e904a51be65b80560518a9b101c604a1a4378673795')

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-${_realname}-${pkgver}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  msg "Python test for ${MSYSTEM}"
  cd "${srcdir}/python-${_realname}-${pkgver}"
  ${MINGW_PREFIX}/bin/python tests/run_tests.py || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-${_realname}-${pkgver}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
   ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING"
}
